import { H3Event } from 'h3'

export const readUser = async (event: H3Event) => {
    // 接收请求体
    const user = await readBody(event)
    // 判断用户请求是否合法
    if (!user || !user.name || !user.password) {
        return {
            timestamp: Date.now(),
            errMsg: '用户名或密码不能为空'
        }
    }
    // 判断密码是否合法
    if (user.password.length < 6 || user.password.length > 12) {
        return {
            timestamp: Date.now(),
            errMsg: '密码格式不正确'
        }
    }
    return user
}
